
(defun dl-s(x dl n)
  (let ((find-list nil))
    (labels ((dl-find (x dl n)
	       
  (if (null dl)
      nil
      (if (dl-p (dl-data dl))
	  (progn (dl-find x (dl-data dl) n)
		 (dl-find x (dl-next dl) n))
	  (progn (if (eql x (dl-data dl))
		     (progn (push dl find-list)
			    (if (= (length find-list) n)
				(return-from dl-s dl))))
		 (dl-find x (dl-next dl) n))))))
	     (dl-find x dl n))))
	  
(defvar *find-list* nil)
(defun dl-f(x dl)
  (if (null dl)
      nil
      (if (dl-p (dl-data dl))
	  (progn (dl-f x (dl-data dl))
		 (dl-f x (dl-next dl)))
	  (progn (if (eql x (dl-data dl))
		     (push dl *find-list*))
		 (dl-f x (dl-next dl))))))
(defun dl-name-count(x dl)
  (setf *find-list* nil)
  (dl-f x dl)
  (length *find-list*))
(defun dl-most-depth(dl)
  (if (null dl)
      0
      (if (dl-p (dl-data dl))
	  (max (1+ (dl-most-depth (dl-data dl))) (dl-most-depth (dl-next dl)))
	  (if (dl-p dl)
	      (max 1 (dl-most-depth (dl-next dl)))))))
(defun dl-depth(dl)
  (if (null dl)
      0
      (if (dl-p (dl-data dl))
	  (let ((depth 0)(t-dl dl))
	    (loop while (dl-p (dl-data t-dl)) do
		 (setf depth (1+ depth)
		       t-dl (dl-data t-dl)))
	    (max depth (dl-depth (dl-data dl)) (dl-depth (dl-next dl))))
	  (if (dl-p dl)
	      (max 1 (dl-depth (dl-next dl)))))))
(defvar *symbol-list* nil)
(defvar *symbol-count* nil)
(defun dl-diff-symbol(dl)
  (setf *symbol-list* nil)
  (dl-d-s dl)
  (length *symbol-list*))
(defun dl-d-s(dl)
  (if (null dl)
      nil
      (if (dl-p (dl-data dl))
	  (progn (dl-d-s (dl-data dl))
		 (dl-d-s (dl-next dl)))
	  (let ((pos (position (dl-data dl) *symbol-list*)))
	    (if pos
	        (incf (nth pos *symbol-count*))
		(progn (push (dl-data dl)  *symbol-list*)
		       (push 1 *symbol-count*)))
	    (dl-d-s (dl-next dl))))))
		